#include "registerrequestmessage.h"

RegisterRequestMessage::RegisterRequestMessage(const Email& email, const Nickname& nickname, const Password& password)
{
    m_messageType = MessageType::RegisterRequest;
    m_email = email;
    m_nickname = nickname;
    m_password = password;
}

RegisterRequestMessage::RegisterRequestMessage(const QJsonObject& jsonObj)
{
    m_messageType = static_cast<MessageType>(jsonObj[JsonKey::TYPE].toInt());
    m_email = jsonObj[JsonKey::EMAIL].toString();
    m_nickname = jsonObj[JsonKey::NICKNAME].toString();
    m_password = jsonObj[JsonKey::PASSWORD].toString();
}

QJsonObject RegisterRequestMessage::PackJsonData() const
{
    QJsonObject jsonObj;
    jsonObj[JsonKey::TYPE] = static_cast<int>(m_messageType);
    jsonObj[JsonKey::EMAIL] = m_email;
    jsonObj[JsonKey::NICKNAME] = m_nickname;
    jsonObj[JsonKey::PASSWORD] = m_password;
    return jsonObj;
}

Email RegisterRequestMessage::getEmail() const
{
    return m_email;
}

Nickname RegisterRequestMessage::getNickname() const
{
    return m_nickname;
}

Password RegisterRequestMessage::getPassword() const
{
    return m_password;
}
